import css from './user.css'
import add from  './component/add';
import {Vue,axios,navigation,commonVue,loadsection} from '../../assets/js/base.js';
import SYS_User_sel from  '../../API/SYS_User_sel.js';
import SYS_User_del from  '../../API/SYS_User_del.js';

new Vue({
    el: '#main',
    data:{
      fullScreen:false,//是否全屏
      currentMenu:"user.html",//当前菜单
      tableLoading:false,
      pageState:false,
      search_data:{
        pageNo:1,
        pageSize:10
      },
      addSettingDialog:false,
      loadSection:false,
      table_data_total:0,
      table_data:[],
      currentID:""
    },
    mounted:function(){
      this.search();
    },
    methods:{
      globalEvent:function(){
        commonVue.$emit('navSelected');
      },
      del(id){
        this.$MessageBox.confirm(`确定要删除吗？`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          SYS_User_del({Id:id}).then(data => {
            this.$Message({
                message:"操作成功"
            });
            this.getTableData();
          }).catch(message => {
            this.$Message({
                message
            });
          });
        }).catch(message => {

        });

      },
      confirmAddSettingDialog(){
        this.addSettingDialog = false;
        this.getTableData();
      },
      openAddSettingDialog(){
        this.addSettingDialog = true;
      },
      cancelAddSettingDialog(){
        this.addSettingDialog = false;
      },
      checkPermission(){
        return true;
      },
      getTableData(){
        this.tableLoading = true;
        SYS_User_sel(this.search_data).then((data,total) => {
          this.table_data = data;
          this.table_data_total = total;
          this.tableLoading = false;
        }).catch(message => {
          this.tableLoading = false;
          this.$Message({
              message
          });
          console.log("SYS_User_sel异常:",message)
        });
      },
      search() {
          this.search_data.pageNo = 1;
          this.getTableData();
      },
      handleSizeChange(pageSize) {
            this.search_data.pageSize = pageSize;
            this.search_data.pageNo = 1;
            this.getTableData();
      },
      handleCurrentChange(currentPage) {
          this.search_data.pageNo = currentPage;
          this.getTableData();
      },
    },
    components: {
      navigation,
      loadsection,
      'add':add,
    }
})
